<?php
if( !defined( 'Nlactus' ) ): define( 'Nlactus', 1 );
if( !defined( 'FILE_ROOT' ) ) include_once( '../path.conf' );
USE_APP('generiquenl');

/**
 * Table Newsletter
 */
USE_APP('Newsletter');
class Nlactus extends Generiquenl
	{
	public function buildForm( $form )
		{
		parent::buildForm($form);
		$f = $form->add( new FormFieldRichCollection( 'f_actualites', 'newsletter', 'actualites', $fieldl='f_newsletter_id', $fieldr='f_actualites_id', $tablenn='newsletter2actualites' ) );
		$f->setRightParams(null,'{F_ACTUALITES_F_DATE_DATE} {F_ACTUALITES_F_TITLE_EXIST}{F_ACTUALITES_F_TITLE}{/F_ACTUALITES_F_TITLE_EXIST}');
		}

	public function elt2html( $tpl, $elt, $prefix )
		{
		parent::elt2html($tpl,$elt,$prefix);
		$ids = "(SELECT f_actualites_id FROM newsletter2actualites WHERE f_newsletter_id={$elt['id']})";
		$tpl->setVarHasMany( $prefix . 'F_ACTUALITES', array(SQL::WHERE=>'id IN '.$ids), 'Actualites', $this, $extras = null, $toeval = null );
		}

	public function elt2htmlPHP( &$elt )
		{
		Format::hasManyIsMany( $elt, 'ACTUALITES', 'newsletter', 'actualites', $displaydepth = 1, $linktable = null, $sqlparams = null );
		}

/*
	public function setSearchFields( &$sproc )
		{
		$sproc->addField('f_title');
		$sproc->addField('f_text');
		}
		
	public function getSearchParams()
		{
		return array(
				'title'=>'Title',
				'head' => '{VAR_F_TITLE}',
				'body' => '{VAR_F_TEXT}',
				);
		}
*/
		
	public function getDisplayDepth() {return 1;}
		
	public function build( $id, Template $tpl )
		{
		}
		
	public function getTplFilename()
		{
		return( APP_ROOT . 'nlactus.tpl' );
		}
		
/*
	public function beforeSend( $eml, $email, $is_test )
		{
		$site = new Newsletter_inscrits;
		$elt = $site->getElementByField( 'f_email', $email );
		$prefix = 'PEOPLE_';
		$eml->setVarDate( $prefix . 'F_DATE', ARRAYVAL( $elt, 'f_date' ) );
		$eml->setVarText( $prefix . 'F_NOM', ARRAYVAL( $elt, 'f_nom' ) );
		$eml->setVarText( $prefix . 'F_PRENOM', ARRAYVAL( $elt, 'f_prenom' ) );
		$eml->setVarText( $prefix . 'F_TELEPHONE', ARRAYVAL( $elt, 'f_telephone' ) );
		$eml->setVarAddress( $prefix . 'F_ADRESSE', ARRAYVAL( $elt, 'f_adresse' ) );
		$eml->setVarText( $prefix . 'F_EMAIL', ARRAYVAL( $elt, 'f_email' ) );
		}
*/
	}
endif;
?>